import React, { lazy, Suspense } from 'react'



const Layout = lazy(() => import('../components/Layout'));
const Login = lazy(() => import('../pages/Login'));
const Home = lazy(() => import('../pages/Home'));
const Account = lazy(() => import('../pages/Account'));
const User = lazy(() => import('../pages/User'));
const Information = lazy(() => import('../pages/Information'));
const Resource = lazy(() => import('../pages/Resource'));
const Banner = lazy(() => import('../pages/Banner'));
const Classification = lazy(() => import('../pages/Classification'));
const NotFound = lazy(() => import('../components/NotFound'));

export interface RouteType {
    children?: RouteType[];
    element: React.ReactNode;
    path: string;
    meta: Record<string, any>
}


const router: RouteType[] = [
    {
        path: '/', meta: { title: "首页", auth: false }, element: (<Suspense><Layout /></Suspense>),
        children: [
            {
                path: '/',
                meta: { title: "首页", auth: true },
                element: (<Suspense><Home /></Suspense>),
            },
            {
                path: '/account',
                meta: { title: "账号管理", auth: true },
                element: (<Suspense><Account /></Suspense>),
            }, {
                path: '/user',
                meta: { title: "用户管理", auth: true },
                element: (<Suspense><User /></Suspense>),
            }, {
                path: '/information',
                meta: { title: "资讯管理", auth: true },
                element: (<Suspense><Information /></Suspense>),
            }, {
                path: '/resource',
                meta: { title: "资源管理", auth: true },
                element: (<Suspense><Resource /></Suspense>),
            }, {
                path: '/banner',
                meta: { title: "Banner配置", auth: true },
                element: (<Suspense><Banner /></Suspense>),
            }, {
                path: '/classification',
                meta: { title: "分类管理", auth: true },
                element: (<Suspense><Classification /></Suspense>),
            }
        ]
    },
    { path: '/login', meta: { title: "登录", auth: true }, element: (<Suspense><Login /></Suspense>), },
    { path: '*', meta: { title: "404", auth: false }, element: (<Suspense> <NotFound /> </Suspense>) },
]

export default router;